#!/bin/bash
rm ~/install.lock
echo `date +"%Y-%m-%d %H:%M:%S" ` 'start' >> ~/install.lock
rm -rf /azerothcore/data/sql
cd /azerothcore
rm *.zip
echo `date +"%Y-%m-%d %H:%M:%S" ` 'download' >> ~/install.lock
argsType=$1
argsVer=$2

wget --no-check-certificate --timeout=10 --tries=2 "http://hx.phasercn.com/download/ac-$argsType-$argsVer.zip"
echo `date +"%Y-%m-%d %H:%M:%S" ` 'unzip' >> ~/install.lock
unzip -q -o "ac-$argsType-$argsVer.zip"


if [ "$argsType" = 1 ]; then
    bash "/azerothcore/apps/db_assembler/db_assembler.sh" import-customs
fi

# http://hx.phasercn.com/down
# http://res.wowmanage.cn/CorePacket

echo `date +"%Y-%m-%d %H:%M:%S" ` 'success' >> ~/install.lock
